Methods and apparatus for unit-distance counting and error-detection

ABSTRACT

A large class of multiple-error-correcting unit-distance counting codes and associated coding apparatus are presented. The class of codes includes the Gray codes, the Kautz codes, and the twisted ring counter codes as subclasses. The class of codes is of special importance because it is generated by counting circuitry which can be simply implemented. Furthermore, a subset of the codes has an easily determined conversion relationship to the ordinary binary counting codes that can be used as the basis for a simple error-detection method.

United States Patent [1 1 [111 3,753,23o Hoffner II Au I4, 1973 METHODS AND APPARATUS FOR 3,569,956 3/1971 Duffy 340/347 on UNIT DISTANCE COUNTING AND 3,588,461 6/l97l Halsall 340/347 DD ERROR-DETECTION OTHER PUBLICATIONS lnvelltofi Charles William Sellers et al., Error Detecting Logic for Digital Com- COlllmbuS, Ohio puters, McGraw-Hill Co., 1968, pp. 197-201. [73] Assignee: Bell Telephone Laboratories,

Incorporated Murray Hill Berkeley Primary Examiner-Charles E. Atkinson Heights, NJ. Attorney-W. L. Keefauver [22] Flledz Jan. 3, 1972 [57] ABSTRACT [2]] Appl' 214622 A large class of multiple-error-correcting unit-distance counting codes and associated coding apparatus are [52] U.S. Cl ..34o/14s.1 AL, 235/92 EC, presented- The class of codes includes the y es 340 14 1 v the Kautz codes, and the twisted ring counter codes as subclasses. The class of codes is of special importance 5 because it is generated by counting circuitry which can e 330/146 1 R 347 -D,D 25 be simply implemented. Furthermore, a subset of the 92GD- 307k 225 codes has an easily determined conversion relationship to the ordinary binary counting codes that can be 56] References Cited used as the basis for a simple error-detection method.

' UNITED STATES PATENTS 5 Claims, 6 Drawing Figures 3,196,258 7/1965 Belcastro 235/92 EC l 2 3 4 r I r l IOO IIO-3 /v IlO-(f-I) IIO-r n OUTPUTS Patented Aug. 14, 1973 3,753,230

3 Sheets-Sheet 3 FIG. .5

FIG. 6

ZI Z2 Z3 Z4 METHODS AND APPARATUS FOR UNIT-DISTANCE COUNTING AND ERROR-DETECTION BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to data processing and data transmission systems and, more particularly, to the detection and correction of errors in information signals processed by those systems.

2. Prior Art The present invention deals with the class of codes known generally as unit-distance counting codes" and typified in the prior art by the well-known Gray codes. These codes, also known as snake-in-the-box (SIB) codes, have been treated in various prior art publications. The general class of counting codes in detailed in a paper by B. Lippel entitled, A Decimal Code for Ana log to Digital Conversion, IRE Transactions, Vol. EC-4, Dec. 1955, pages 158-159. This paper includes extensions of still other prior art teachings including those described in U.S. Pat. No. 2,632,058, issued Mar. 17, 1953, to F. Gray. The codes described in the latter patent are, of course, the well-known Gray codes, themselves. A sequel to the above-cited Lippel paper by H. E. Tompkins, Unit Distance Binary Codes for Two-Track Commutation," IRE Transactions, Vol. EC-S, Sept. 1956, page 139, describes a generalization of the basic Gray code concepts to other than the exact Gray code configuration.

Additional codes related to the unit-distance counting codes are described in R. K. Richards, Arithmetic Computations in Digital Computers, Van Nostrand, New York, 1955, and I. Flores, Reflected Number Systems, IRE Transactions, Vol. EC-5, June 1956, pages 79-82. In addition, W. H. Kautz, Unit-Distance Error-Checking Codes," IRE Transactions, Vol. EC-7, June 1958, pages 179-180, describes a generalization of the basic unit-distance code concepts for purposes of achieving error checking. A more recent paper by Kautz illustrates a particular class of unit-distance counting codes with error checking capabilities. Specifically, this last-mentioned class of codes is described in W. H. Kautz, A Readily Implemented Single-Error- Correcting Unit-Distance Counting Code, IEEE Transactions, Vol. C-19, Oct. 1970, pages 972-975. Other literature references useful in connection with a review of the general field of unitdistance counting codes are R. C. Singleton, Generalized Snake-in-the- Box Codes," IEEE Transactions, Vol. EC-l5, Aug. 1966, pages 596-602; R. T. Chien, C. V. Freiman, and D. T. Tang, Error Correction and Circuits on the n- Cube," Proceedings Second Allerton Conference on Circuit and System Theory, pages 899-912, 1964; and E. N. Gilbert, Gray Codes and Paths on the n-Cube," BSTJ, Vol. 37, 1958, pages 815-826.

The above-described prior art publications have been directed primarily to techniques for simply characterizing and enumerating optimal codes (optimal in the sense of having the maximum number of code words for' a given word length) and to only the very basic as-' pects of methods and apparatus for counting and error checking. Except for a specialized design for singleerror-correcting counting codes, complicated apparatus was required for error checking systems using counting codes. Further, such apparatus was necessarily designed on a costly and time-consuming per code basis.

It is therefore an object of the present invention that a class of multiple-error-correcting counting codes, and programmable" counting apparatus for implementing those codes, be provided.

It is an additional object of the present invention that a simple economical error checking method and apparatus for pulse code systems be provided.

SUMMARY OF THE INVENTION An important aspect of the present invention relates to the generalization of the above-mentioned Kautz and Gray codes and the manner of implementing this larger class of codes. In particular, codes that can correct an arbitrary number of errors may be generated in a straightforward manner by a combination of wellknown simple hardware elements. In short, a clock circuit provides signals to an array of identical so-called twisted ring counters. The output signals from the array of twisted ring counters constitute the particular patterns for a code word.

Each of the twisted ring counters is activated in accordance with the present invention by the output signals from a respective portion of the clock circuit and there is no interaction among the twisted ring counters. The clock circuit, in turn, assumes the particularly simple form of a standard r-stage Gray code counter. In particular, when an output from that stage of the Gray code counter associated with a specific twisted ring counter experiences a change of state, the corresponding twisted ring counter is advanced to a new state, thereby generating a new code word in the counting sequence. The error-correcting capability of the instant codes derives from the fact that not all possible words are valid code words. It is thereby possible to detect errors by determining when an invalid code word has been received.

Another important aspect of the present invention relates to the manner of accomplishing error detection. Briefly, when an n-digit codeword is received from a transmission channel, it is temporarily stored. in addition, a doubly transformed version of this received code word is generated. A forward transformation in accordance with the present invention is performed in a prescribed many-to-one fashion, thereby realizing an m-digit word which is not uniquely associated with a particular input n-digit code word. A reverse transformation in accordance with the present invention is performed in a prescribed one-to-one fashion, thereby realizing an n-digit doubly transformed code word which is uniquely associated with a particular input mdigit word. Because of the properties of the transformations, the doubly transformed code word will be the same as the original received code word if and only if the original received code word was a valid code word.

Acordingly, a comparison is made at the receiver between the originally received (and temporarity stored) code word and the doubly transformed version of it. If a positive comparison is indicated, it is certain that the received code word was a valid code word; if a negative comparison is made, it necessarily follows that the received code word was not a valid code word. In the latter instance, an error in the received code word will have been detected. The circuitry for implementing the indicated double transformation and comparison assumes a particularly simple form for a certain subclass of the general class of codes disclosed.

It is a feature of the present invention that simplified techniques and circuitry are provided for detecting errors in data transmission systems.

It is a further feature of the present invention that particularly efficient counting circuitry is provided for use in systems processing pulse-coded information. It is a more specific feature of the present invention that standard-design Gray code counters are used for producing clocking signals for an array of standard-design twisted ring counters to generate the counting sequence.

BRIEF DESCRIPTION OF THE DRAWING The above and other objects and features of the instant invention will be more fully understood upon considering the detailed description of an illustrative embodiment in connection with the attached drawing wherein:

FIG. 1 is a block diagram representation of the general configuration for apparatus for generating words of a counting code in accordance with one aspect of the instant invention;

FIG. 2 is a particular example of circuitry for realizing the counting apparatus of FIG. 1 for the special case of r= 3 and t l, where r and t are defined below;

FIG. 3 is a timing diagram illustrating the sequence of clock signals and resulting state-indicating signals for the circuit of FIG. 2;

FIG. 4 shows the overall organization of errordetection apparatus using codes in accordance with the instant invention;

FIG. 5 illustrates an encoder circuit for use with the apparatus of FIG. 4 for the case of r 3, t= l; and

FIG. 6 illustrates a decoder circuit for use with the apparatus of FIG. 4 for the case of r 3, t= 1.

DETAILED DESCRIPTION Theoretical Considerations for Code Construction Before proceeding to a detailed description of a typical embodiment of apparatus in accordance with the instant invention, and the manner in which this and similar hardware may be used to effect the desired processing in accordance with the instant invention, it will prove useful to review and formalize certain definitions and rules of notation. These definitions and rules of notation will then be used to derive a number of useful mathematical results and to construct a new class of unit-distance counting codes. Succeeding sections will then present apparatus for generating and utilizing these codes.

To help in focusing on the essential results of these preliminary analyses, it is here noted that the codes obtained have length n r(t+l) and distance k 2t+l. Further, there are K (t+l)2 code words where t 24 0 and r 2 2. The codes permit t errors to be corrected or 2t errors to be detected and are said to be multiple-error-correcting. It should also be noted that it is an inherent property of multiple-error-correcting unit-distance counting codes that correction or detection will sometimes displace a code word in the counting sequence; the displacement will be negligibly small, no more than 2: counts, as long as the number of errors does not exceed the error checking capability of the code.

A unit-distance counting code is an ordered sequence of q-ary vectors or words such that each vector differs from the preceding vector in exactly one component, and the first vector differs from the last vector in exactly one component. A K x n matrix C whose j"' row is 0,, l s j s K, will be called a code if its row vectors form a unit-distance counting code when taken in sequence c c c c c Unless otherwise stated, it will be assumed that the vectors are binary, that is, q 2. The symmetrical K K matrix D [d where d is the number of components in which c, and c, are different, will be called the distance matrix for C.

If C is a code and d 2 k for each pair of code vectors 0,, c, that are separated in the counting sequence by k or more, then the code is said to have distance at least k; for j 2 i the separation of c, and c, is simply the smaller of j-i and K( j-i). If a code has distance at least k, then d is equal to the separation of c, and 0, when their separation is less than k. A code is said to have distance exactly k if it has distance at least k but does not have distance at least k+l.

Let A [a be the K X K matrix such that a d when d s k and a k when d k. Let E be the K X K circulant matrix whose first row is Then if the columns of C are partitioned into two submatrices C C with distance matrices D D respectively, and A A; are computed from D D respectively, the validity of the following LEMMAs is obvious.

LEMMA 1: A code has distance at least k if and only if A E.

LEMMA 2: If C= [C C then D D,+D

LEMMA 3: If C [C C then C is a code with distance at-least k if and only if A,-lA 2E.

LEMMA 4: If D is a circulant matrix and d is the first row of D, then C is a code with distance at least k if and only if d z e.

The inequality D 2 A means that d a 1 i s K, 1 s j s K. When the properties of circulants can be used, the determination of k is greatly simplified.

DEFINITION: If K is an even multiple of n and if for c, (w W2 w w w,, it is true that c, (w W W w,, w, W is j s K-l, where the value of W, is w,+l modulo 2, then C is called a twisted ring counter code.

It follows from the definition that each column of a twisted ring counter code is a cyclic shift of the rightmost column, and that c, 0 1 j S K-2n. From these observations, the validity of the following LEM- MAs is obvious.

LEMMA 5: The distance matrix for a twisted ring counter code is circulant matrix.

LEMMA 6: A twisted ring counter code is a unitdistance counting code if and only if K 2n and c, is the all-zero vector for some j; the distance of the code is k n.

The term twisted ring counter code will be used in the sequel to refer only to those twisted ring counter codes for which c, is the all-zero vector for some j. The for a twisted ring counter code, d (h h h h h h) where d is the first row of D and the subvector h (0 l 2 n-l n nl 2 l) is repeated K/2n times.

Note that if C [C C is a code, then at least one of C and C is not a code. Furthermore, if either C, or C is a code, then C is a code only if the rows of the other matrix are all the same. These simple observations suggest a method of modifying two codes so that if C, and C are modified codes, then C is a code.

Let C* be the 2K x n matrix related to C by 0%., c* ,=c,, l j s K. Let C** be the 2K Xn matrix related to C by c**,,., c**,,., 0,, 2 sj s K, and c, c c,. Let D" be the distance matrix for C". Then row 2j-1 of D* is the same as row 2j and column 2j-l of D* is the same as column 2j, l s j s K. Let D** be the distance matrix for C. Then row 2j2 of D is the same as row 2j-l row 1 of D** is the same as row 2K, column 2j-2 of D** is the same as column 2jl, the column 1 of D** is the same as column 2K, 2 s j s K. A* and A** are computed from D* and D** LEMMA 7: If C, and C are code matrices having K, and K rows, respectively, and K, K,, then the matrix [0, C is a code.

THEOREM 1: If C= l(*, C**,], where K= 2K, =2K C, has distance at least k I 21+l and (f, is a twisted ring counter code with 1+1 columns, then has distance exactly k.

PROOF: C is a code from LEMMA 7. Since D, 2 A", and D", 14",, the code has distance at least k if and only if A*,+A** B E from LEMMA 3. Let S A*,+A** and let s be the first row of S. From LEMMA 1, A, is a circulant matrix and, from LEMMA 5, A is a circulant matrix. It follows that for both A*, and A**,, and therefore for S, each odd numbered row is a cyclic shift of the first row, and each even numbered row in a cyclic shift of the second row. The first row ofA is (001 122 k1 k1 k k k k k k k k k-l k-l 221 l) and the second row of A*, is the same as the first. The first row of A"* is (01 l22...t t t+l 1+1 t t...221100l122...t t t+l 2+1 t t...22l and the second row of A** is the first row shifted cyclically two positions to the right. Note that, because of symmetry, the even numbered rows of S are the odd numbered rows written in reverse order. Consequently, recalling LEMMA 4, the code has distance at least k if and only if s 2 e. Now s is the sum of the first row of A*, and the first row of A*",. Let s (s, s s s,, s Then an examination of the first row of A*, reveals that s, 2 k for 2k+l i s K-2k+2. Furthermore, since k 2t+l, the first 2k components ofs are 0 l 2 3 kl k k+l k k+l k k+l k and the last 2k-2 components of s are k+l k+2 k+l k+2 k+l k+2 k+l kkl 3 2 1. Thus, s 2 e and the code has distance exactly k.

COROLLARY: For any t 2 0 and any r 2 2, there exists a code with n r(t+l k 2t-+-l, and K= (t+l )2" PROOF: For n 2(t-l-l a twisted ring counter code with K 2n has distance k n from LEMMA 6. If such a code is used as C, in the THEOREM, a new code with n 3(t+l K= 4n, and k= 2t+l results. The new code can then be used as C, in the THEOREM. Repetitive application of the THEOREM yields additional codes. Assume a code exists with n (rl)(t+l), k 2t+1, and K (ti-l)2" where t 2 0 and r 2 3. If this code is used as C, in the THEOREM, a new code with n r(t+l), k=2t+l, and K=(t+l)2 results. Thus, for any 1 2 0 and any r 2 2, there exists a code with n r(t+l k 2t+l, and K (1+1 )2.

The class of codes described in the COROLLARY is a generalization of three other classes of codes in the sense that it includes these classes as subclasses. The codes for r 2 are twisted ring counter codes. The codes for t 0 are the well-known Gray codes. The codes for t =1 are equivalent to the Kautz codes; codes are said to be equivalent if they differ only in a permutation of columns.

The first 2(t+l) columns of the class of codes described in the COROLLARY can be permuted to obtain an equivalent calss of codes with a simple representation. Let C be a twisted ring counter code with r+l columns and (1+1 )2 rows and let C, be a twisted ring counter code with t+l columns and 2(t+l) rows. Then C [C, C**,] is a twisted ring counter code with its columns permuted. Repetitive application of the relation C, [C', 0"], i= 2,3,4, for a given value of t, yields a family of codes C,, C,, C,, with a convenient recursive representation. Matrix C,, r= 1,2,3. will be used in the sequel to refer specifically to the code in this family that has n r(r+l) columns, K (1+1 )2 rows, and distance k= 2t+l It will be assumed that the first rows of C and C,, and therefore of C,, are all-zero.

Counting Circuitry The above-mentioned recursive representation dietates one possible hardware implementation with the codes presently of interest. FIG. 1 is a representation of a general configuration of hardware elements useful in generating the desired code words. FIG. 1 shows an r-stage Gray code counter 100. As is typical for Gray code counters, there are generated on the set of r output leads a pattern of r bits which form the code words for a Gray code. The fundamentals of Gray codes and their associated counters are well known in the art and are described, for example, in U. S. Pat. No. 2,632,058, issued Mar. 17, 1953, to F. Gray.

Each of the outputs of Gray code counter is connected as the input to a respective twisted ring counter IlO-i, i= l,2,...,r. Twisted ring counters are also well known in the art and are described, for example, in W. Bleiekardt Multimoding and Its Suppression in Twisted Ring Counters, BSTJ, Vol. 47, Nov. 1968, pp. 2029-2050, and references cited therein. The twisted ring counters each have t +1 stages and therefore have 2(t+l) states.

To generate the desired set of code words it is assumed that all counters are initialized to 0 and that the twisted ring counters ll0--i advance to their next state when the respective Gray code counter output changes from 0 to l or from I to 0. Thus, in effect, the Gray code counter supplies a plurality of clock signals for application to the respective twisted ring counters. As the clock circuit (Gray code counter) 100 advances through its sequence of states, the outputs from the r separate twisted ring counters provide the required n outputs to generate the n-digit code words of C FIG. 2 is a typical circuit realization of the generalized counting apparatus shown in FIG. 1 for the case r 3 and t l. The associated counting sequence appears in Table I.

TABLE I x, x, x, x, x, x, Y, Y, Y z, 2, Z, 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 o 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 0 0 0 0 1 1 1 o 1 o 0 1 1 o 1 0 1 1 1 1 1 0 1 0 0 0 1 0 1 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 1 0 0 1 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 0 1 0 1 1 o 1 0 1 1 1 0 1 1 0 1 0 0 1 1 1 0 1 0 1 1. 1 1 0 1 0 0 ll) l I0 I I 1101 I0 00 l0 1 O l ()l O 1 0 0 0 0 0 1 0 0 0 1 1 The output from the unit-distance coutner of FIG. 2 is, of course, X (X X X X and n =r(t+l).

Each of the elements shown in FIG. 2 is a standard J-K flip-flop such as the Texas Instrument tupe SN7470. A clear lead 201 is used to initially set the two flip-flops 202 and 203 to their 0 states. Simultaneously, the J-K flip-flop in each of the two-stage twisted ring counters are also set to 0. That is, flip-flops 2lO-i and 21 l-i, i= I2 and 3, are set to 0. As will be clear to those skilled in the art, twisted ring counters constructed from J-K flip-flops count only when the clock makes a transition from O to 1. Thus, the outputs from an ordinary (r-l )-stage binary counter can be used to provide the clock signals. This follows from the following observation: for a Gray code counter, exactly one output makes a transition for each count; for an ordinary binary counter, at most one output makes a ZERO to ONE transition for each count. Furthermore, if Z= (2,2 2 Z, is the output of an ordinary (r-l)- stage binary counter and Y =(Y Y l Y,.) is the output of an r-stage Gray code counter, and if both counters are initialized to all-zero, then 2. will make a ZERO to ONE transition each time Y makes a transition, 1 1 s r-l, and 2, will make a ZERO to ONE transition each time Y makes a transition.

FIG. 3 shows a timing chart for the various signals appearing during the operation of the circuit of FIG. 2.

It should be clear that alternate means are available for providing the required clocking signals for the case of r 3 and t 1. In fact, for other particular values for r and I still other simplifications and/or degeneracies will occur.

Theoretical Considerations for Encoding and Decoding A binary counting code is an ordered sequence of mcomponent binary vectors or words such that the numerical value of each vector is one more than the numerical value of the preceding vector modulo 2". An N X m matrix B whose row is by, l s j s N, will be called a binary code if N is divisible by 2 and its row vectors form a binary counting code when taken in sequence b,, b b b,., b Let 8* be the 2N X m matrix related to B by b; b* b,, 1 s j s N. The validity of the following LEMMA is obvious.

LEMMA 8: IfB is a l/2 N X (m-l binary code and B is an N l binary code, then [B" B ]is a binary code.

Let B be a binary code with one column and 2 rows and let B be a binary code with one column and two rows. Then repetitive application of the reltion B, [B*, B], i= 2,3,4, yields a family of binary codes 8,, B B with a convenient recursive representation. Matrix B,,,, m 1,2,3, will be used in the sequel to refer specifically to the code in this family that has m columns and 2" rows. It will be assumed that the first rows of B and B and therefore B,,,, are all-zero.

The error detection method to be developed can be described as follows. Suppose I 1 =2" so that K 2". Suppose also that a set of equations that permit conversion back and forth between row b, of B, and row c, of C,- are known, 1 s i s 2". The decoding equations that convert c, to b, will convert an arbitrary ncomponent binary vector w into some row of B,,,. If this row is 12,, then the encoding equations that convert b, to 0, will convert b, to 0,. Now if w is row i of C,, that is, if w c then c, =c, and c w. But if w is not a row of C,, then c, a w. Thus, any set of equations that permit conversion back and forth between B and C, can be used to determine if an arbitrary n-component binary vector w is a code word. If w is not a code word, then an error condition has been detected.

It will be assumed in the sequel that t l 2"'" so that K 2'". The m-component binary vector Z= (Z, Z, 2;, 2, will be used to denote a row of B,, and the n-component vector X =(X X X X,,) will be used to denote the corresponding row of C The set of equations relating Z to X and X to Z will be considered.

The odd numbered rows of C, contain an even num ber of ONEs and the even numbered rows of C, contain an odd number of ONEs. It follows from this observation that for m-H-l s i s m Let C be a twisted ring counter code with H-l columns and 2(t 1) rows. Let B be a binary code with m-r=l columns and 2""" rows. Let C be the (t+l )2" X (1+1) matrix related to C by '1 C11 0- s i 1'0")- Let B be the 2'" X (m-H-l) matrix related to B by The submatrix consisting of the first t-l-l columns of C, is C. The submatrix consisting of the first m-r+l columns of B is B. It follows from this observation that Z, for l s i s mr+l can be expressed in terms of those X, with l sj 5 2-1. It is easily verified that for l fii s m-ri-l For any I B 0 and any r 2 1 these formulas provide a full set of m equations relating Z to X.

Now X, for is j S t+l can also be expressed in terms of those Z, with l s is m-r-i-l. For r B 2 the submatrices consisting of the last t+1 columns of C,- and the last mr+2 columns of B,,,, respectively, are

where there are 2" repetitions of C", and of B,,, These observations establish the following LEMMAs.

LEMMA 9: For 1 sj s t+l, X, can be expressed in terms of those Z, with 1 s i s m-r+l.

LEMMA 10: For 1 sp 5 rl and p(z+l)+1 s j (p+l )(t+l X, can be expressed in terms of those 2, with p s i s p-i-m-r+l.

LEMMA 11: For t+2 shs n and t+2 j n, X and X differ in a transfomration of variables if and 9 only ifj, E jg modulo t+l; and, ift+2 $1, $2(t+1) and j =j,+(p1)(t+l) for some p, 1 5p$r1, then the required transformation of variables is accomplished by replacgig X with X and Z, with Z 1315 m r 2.

Two equations are said to be in the same equivalence class if they differ only in a transformation of variables. Although there are n r(t+l) equations relating X to Z there are only 2(t-l-1 equivalence classes; each of the equations for X j with 1 5t+1, forms an equivalence class. This property greatly reduces the computational task of determining the n equations. The computational task is also reduced by the fact that the equations for the code with parameter m-r differ from half the equations for the code with parameter m-r-I-l by transformation of variables.

For example, if t then m =n =r and the equations are the well-known equations that relate the Gray and binary codes,

If t 1 then n 2m--2 and the equations are 2J+1 1 ZJ+1 ZJ+2 1 j {1- I and 10 Equations for M-r 2 are easily obtained and will not be listed.

If Y is the row of a Gray code, with m columns and 2" rows, that corresponds to X and Z, then equations relating Y to X are readily found:

Note that X Y when t= 0.

Error Dectection Circuitry From the above discussion, it becomes clear that the presently developed class of counting codes may be used to advantage in systems requiring accuracy in received data (such as pulse code communication systems) as well as in reliable control and data processing systems. FIG. 4 illustrates the general configuration for error-detection apparatus in accordance with the instant invention.

Thus, an arbitrary n-digit word is shown being received on input lead 401. This input word is temporarily stored in memory 402 and delivered to decoder 403. Decoder 403 performs the X to Z transformation de-' scribed above. Next, the vector resulting from the X to Z transformation is itself transformed by encoder 404. If the original received vector w was a valid code word, a row c, in the matrix C,, then the double transformation will yield the same received vector w c,. If w was not a valid code word, w c, for any j, then the double transformation will not yield the same received vector. Thus, comparator 405 is used to compare the result of the Z to X transformation with the received Z vector stored in memory 402. If an error is detected, an appropriate alarm signal is generated as the output from comparator 405; otherwise, the received vector may be cleared from memory 402 and delivered to an appropriate utilization circuit. In other circumstances, the mere verification of the validity of the vector w is all that is required.

To further illustrate the manner of making and using the instant invention, typical circuits for performing the decoding and encoding operations indicated in FIG. 4 will be presented. In particular, the appropriate transforming circuitry used with the code words associated with the counting circuit of FIG. 2 will be presented.

Thus, for the case r=3 and 1 =1, the circuits of FIGS. 5 and 6 comprising a number of NAND gates may be used to perform the encoder and decoder functions, re spectively. It is apparent from FIGS. 5 and 6 that the corresponding X and Z vectors, shown in Table II, can

be generated therefrom.

TABLE ll 21 2 Z3 Z4 X1 1 3 4 11 11 0 o o 0 o 0 0 0 0 0 0 0 0 1 0 o o 0 0 1 o 0 1 0 o 0 0 1 o 1 o 0 1 1 0 0 0 1 1 1 0 1 0 0 0 1 o 1 1 1 o 1 0 1 o 1 o 1 1 0 ----oooo-- ---oo---oo-- -o-o--o--o--c oooo----- oooooo--- o-----ooooooo-----ooo Conclusions, Extensions and Generalizations A class of codes that is easy to count, and that contains families of codes that are easy to convert to and from ordinary binary codes, has been presented and an error detection method for codes with 2" words has been described. The codes are highly structured and it is perhaps because of this fact that counting, encoding and decoding are relatively simple.

The structure of these codes can be characterized as follows: Each column of the K x n code matrix consists of alternating spans of ZEROs and ONEs such that all spans of a given column have the same length. If column i, l s isn. consists of u, spans of length v then u, is even,

If K =2" such codes have relatively simple conversion relationships to the ordinary binary counting codes.

Although the detailed description above has proceeded in terms of binary codes, it is clear that the construction and implementations can be readily extended to obtain nonbinary unit-distance counting codes, that is, codes for which q 2. For example, ifK is a multiple of qn and if for c, (w w w w,, w, w,,) it is true that o (W2 W w w,, w W is j K-l, where the value of w, is w +l modulo q, then is called a q-ary twisted ring counter code.

Numerous and varied other modifications and variations within the spirit and scope of the attached claims will occur to those skilled in the art.

What is claimed is:

1. Apparatus for generating a sequence of code words comprising a. a first counter responsive to an applied input sequence of clock pulses for generating stateindicating signals on a first leads, and

b. a plurality of additional counters, each responsive to signals appearing on a respective one of said first plurality of output leads from said first counter for generating a component of said code words on a second plurality of output leads, the ordered output from the totality of said additional counters, representing said code words wherein said first counter comprises means for changing the signals on only a single output lead in response to a given clock pulse.

2. Apparatus according to claim 1 wherein said first counter comprises an r-stage Gray code counter.

3. Apparatus according to claim 2 wherein each of said additional counters comprises a (1+1 )-stage twisted ring counter.

4. Apparatus for detecting an error in a first n-digit word comprising a. means for transforming said first n-digit word into a corresponding m-digit word in accordance with a many-to-one relationship,

b. means for transforming said m-digit word into a second n-digit word in accordance with a one-toone relationship, and

c. means for comparing said first n-digit word with said second n-digit word whereby an error in said first n-digit word will result in a signal generated by said means for comparing, said signal corresponding to a dissimilarity in said first and second n-digit words.

5. A method for detecting an error in a first n-digit word comprising the steps of a. transforming said first n-digit word into a corresponding m-digit word in accordance with a manyto-one relationship,

b. transforming said m-digit word into a second ndigit word in accordance with a one-to-one relationship, and

c. comparing said first n-digit word with said second n-digit word such that an error in said first n-digit word is detected when said first and second n-digit words are not the same.

plurality of output 

1. Apparatus for generating a sequence of code words comprising a. a first counter responsive to an applied input sequence of clock pulses for generating state-indicating signals on a first plurality of output leads, and b. a plurality of additional counters, each responsive to signals appearing on a respective one of said first plurality of output leads from said first counter for generating a component of said code words on a second plurality of output leads, the ordered output from the totality of said additional counters, representing said code words wherein said first counter comprises means for changing the signals on only a single output lead in response to a given clock pulse.
 2. Apparatus according to claim 1 wherein said first counter comprises an r-stage Gray code counter.
 3. Apparatus according to claim 2 wherein each of said additional counters comprises a (t+1)-stage twisted ring counter.
 4. Apparatus for detecting an error in a first n-digit word comprising a. means for transforming said first n-digit word into a corresponding m-digit word in accordance with a many-to-one relationship, b. means for transforming said m-digit word into a second n-digit word in accordance with a one-to-one relationship, and c. means for comparing said first n-digit word with said second n-digit word whereby an error in said first n-digit word will result in a signal generated by said means for comparing, said signal corresponding to a dissimilarity in said first and second n-digit words.
 5. A method for detecting an error in a first n-digit word comprising the steps of a. transforming said first n-digit word into a corresponding m-digit word in accordance with a many-to-one relationship, b. transforming said m-digit word into a second n-digit word in accordance with a one-to-one relationship, and c. comparing said first n-digit word with said second n-digit word such that an error in said first n-digit word is detected when said first and second n-digit words are not the same. 